import '../../../app_files.dart';

class AccountItemModel {
  final name;
  final accountNo;
  final address;
  final mobile;

  const AccountItemModel({
    this.name,
    this.address,
    this.accountNo,
    this.mobile,
  });

  static fromJson(Map<String, dynamic> json) {
    return AccountItemModel(
      name: CommonUtils.checkNullToString(json['UserName']),
      accountNo: CommonUtils.checkNullToString(json['UserNo']),
      mobile: CommonUtils.checkNullToString(json['UserMobile']),
      address: CommonUtils.checkNullToString(json['UserAddress']),
    );
  }
}

class GasAccountModel {
  final String itemId;
  final String title;
  final String gasNo;
  final String bluetoothNo;
  final String address;
  final String ctrlCode;
  final String userID;

  bool get isICUser => ThemeConfig.supportCtrlCode.contains(ctrlCode);

  bool get isXABleUser => ctrlCode == 'XALYK';

  const GasAccountModel({
    this.itemId,
    this.title,
    this.gasNo,
    this.bluetoothNo = '',
    this.ctrlCode = 'XA',
    this.address = '',
    this.userID,
  });

  static fromJson(var json) {
    return GasAccountModel(
      itemId: CommonUtils.checkNullToString(json['BindId']),
      title: CommonUtils.checkNullToString(json['BindUserName']),
      gasNo: CommonUtils.checkNullToString(json['BindUserNo']),
      userID: CommonUtils.checkNullToString(json['BindUserId']),
      bluetoothNo: CommonUtils.checkNullToString(json['BindBluetoothNo']),
      address: CommonUtils.checkNullToString(json['BindUserAddress']),
      ctrlCode: CommonUtils.checkNullToString(json['BindMeterCtrlCode']),
    );
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is GasAccountModel &&
          runtimeType == other.runtimeType &&
          itemId == other.itemId;

  @override
  int get hashCode => itemId.hashCode;
}
